<template>
  <el-drawer
    v-model="drawer"
    title="I am the title"
    :direction="direction"
    class="drawer-wrapper"
  >
    <template #header>
      <div class="header-wrapper">
        <div>
          <span class="line" />
          <span class="title">合同生命周期</span>
        </div>
      </div>
    </template>
    <el-timeline>
      <el-timeline-item
        v-for="(item, index) in activities"
        :key="index"
        color="#BBD8FF"
      >
        <div class="timeline">
          <span class="timestamp">
            {{ item.timestamp }}
          </span>
          <div class="content-wrapper">
            <span class="title">{{ item.content }}</span>
            <div class="desc-wrapper">
              <span class="content">{{ item.content }}</span>
              <span class="desc">{{ item.desc }}</span>
            </div>
          </div>
        </div>
      </el-timeline-item>
    </el-timeline>
  </el-drawer>
</template>

<script>
import { ref } from 'vue'

export default {
  setup() {
    const drawer = ref(false)
    const direction = ref('rtl')
    const activities = [
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      },
      {
        content: '合同下载',
        timestamp: '2018-04-15 16:21:12',
        desc: '用户：张展溪（zhangzhanxi@itcast.cn），操作“下载”'
      },
      {
        content: '合同作废',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：学员操作“作废”合同'
      },
      {
        content: '合同预览',
        timestamp: '2018-04-15 16:21:12',
        desc: '执行成功：创建合同签订记录'
      }
    ]
    function show() {
      drawer.value = true
    }
    return {
      drawer,
      direction,
      activities,
      show
    }
  }
}

</script>

<style scoped lang="scss">
.header-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  .line {
    display: inline-block;
    width: 4px;
    height: 12px;
    margin-right: 8px;
    background: #247ffc;
    border-radius: 2px;
  }
  .title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
  }
}
.timeline {
  display: flex;
  font-size: 14px;
  color: #333;
}
.timestamp {
  text-align: center;
  width: 80px;
}
.content-wrapper {
  margin-top: -2px;
  width: 310px;
  margin-left: 30px;
  .title {
    display: inline-block;
    font-weight: 500;
    margin-bottom: 8px;
  }
}
.desc-wrapper {
  display: flex;
  .content {
    margin-right: 10px;
    white-space: nowrap;
    font-size: 12px;
    color: #247ffc;
  }
  .desc {
    font-size: 12px;
    color: #666;
  }
}
</style>